package random;

import bibliotekosis.User;
import java.awt.Component;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import java.awt.Component;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

public class UserTableModel extends AbstractTableModel
{
    private String[] columnNames = { "ID", "Vardas", "Pavardė", "A.K." };
    private Object[][] data =null;

    public UserTableModel(List<User> users)
    {
        data = new Object[users.size()][3];
        
        int i = 0;
        for (User u : users) {
            data[i++] = new Object[] {u.get("id"), u.get("name"), u.get("surname"), u.get("person_code")};
        }
        
    }
    
    
    
    @Override
    public Class getColumnClass( int column ) 
    {
        return getValueAt(0, column).getClass();
    }
    @Override
    public int getColumnCount() 
    {
        return columnNames.length;
    }
    @Override
    public String getColumnName( int column ) 
    {
        return columnNames[column];
    }
    @Override
    public int getRowCount() 
    {
        return data.length;
    }
    @Override
    public Object getValueAt( int row, int column ) 
    {
        return data[row][column];
    }

}